var url = window.location.pathname;
mui.init({
    swipeBack: false,
    pullRefresh: {
        container: '#mui-content',
        up: {
            contentrefresh: '正在加载...',
            callback: pullupRefresh
        }
    }
});
var index = 1;
var title = $("input[name='title']").val();
function pullupRefresh() {
    setTimeout(function () {
        var count = Math.ceil(($("input[name='current']").val()) / 11);
        ++index;
        if (index<=count) {
            mui('#mui-content').pullRefresh().endPullupToRefresh(false);
            ajaxList(index);
        }else {
            mui('#mui-content').pullRefresh().endPullupToRefresh(true);
        }
    }, 1000);
}
$(".custom-search-span").on("tap", function () {
    $(".mui-search").attr("action", url).submit();
});
$(".mui-navigate-right").off("tap").on("tap",function () {
    var href=$(this).attr("href");
    window.location.href=href;
});
function ajaxList(pager) {
    $.ajax({
        type: "GET",
        dataType: "json",
        data: {"content": pager, "title": title},
        url: "/uc/schedule/ajax/user/db",
        error: function () {
            console.log("连接异常！");
        },
        success: function (data) {
            if (null != data && "" != data) {
                var dataList = data.dataList;
                var html = "";
                if (null != dataList && dataList.length > 0) {
                    for (var i = 0; i < dataList.length; i++) {
                        html = html + "<li class='mui-table-view-cell mui-media'>" +
                            "<a class='mui-navigate-right' href='" + dataList[i].url + "'>" +
                            "<div class='mui-media-body mui-ellipsis'>" +
                            "<span>" + dataList[i].title + "</span>" +
                            "<p class='mui-ellipsis custom-ellipsis-size'>" + dataList[i].sqr + " / " + dataList[i].workname + " / " + dataList[i].description +
                            "</p></div></a></li>";
                    }
                }
                $(".custom-lecture").append(html);
                $(".mui-navigate-right").off("tap").on("tap",function () {
                    var href=$(this).attr("href");
                    window.location.href=href;
                });
            }
        }
    });
}